/*
 * Copyright 2013 Aliyun.com All right reserved. This software is the
 * confidential and proprietary information of Aliyun.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Aliyun.com .
 */
package com.mtauto.model;

import java.io.Serializable;

/**
 * @author <a href="mailto:li.jinl@alibaba-inc.com">Stone.J</a> Nov 21, 2013
 */
public class Result<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private boolean           success;
    private T                 data;
    private String            message;

    public static final <T> Result<T> createResult(T data) {
        Result<T> r = new Result<T>();
        r.setSuccess(true);
        r.setData(data);
        return r;
    }

    public static final Result<Void> createFailResult(String message) {
        Result<Void> r = new Result<Void>();
        r.setSuccess(false);
        r.setMessage(message);
        return r;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
